package main

import (
	"fmt"
	"strconv"
)

func main() {

	//其他类型转成字符串
	//func Sprintf(format string, a ...interface{}) string
	var num1 int = 100
	var num2 float64 = 9.16
	var b bool = true
	var mychar byte = 'h'
	var str string

	str = fmt.Sprintf("%d", num1)
	fmt.Printf("str type=%T str=%q\n", str, str)

	str = fmt.Sprintf("%f", num2)
	fmt.Printf("str type=%T str=%q\n", str, str)

	str = fmt.Sprintf("%t", b)
	fmt.Printf("str type=%T str=%q\n", str, str)

	str = fmt.Sprintf("%c", mychar)
	fmt.Printf("str type=%T str=%q\n", str, str)

	//
	var num3 int = 99
	var num4 float64 = 21.2121
	var b2 bool = true

	str = strconv.FormatInt(int64(num3), 10)
	fmt.Printf("str type=%T str=%q\n", str, str)

	//保留10位小数, float64类型
	str = strconv.FormatFloat(num4, 'f', 10, 64)
	fmt.Printf("str type=%T str=%q\n", str, str)

	str = strconv.FormatBool(b2)
	fmt.Printf("str type=%T str=%q\n", str, str)

	// i to a ==> Itoa
	var num5 int = 123
	str = strconv.Itoa(num5)
	fmt.Printf("str type=%T str=%q\n", str, str)

}
